﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Stone.DataContracts;
using Stone.Library.Common;

namespace CourseArraging.Frm.jygl
{
    public partial class FrmTecZmCondi : Form
    {
        public enum FrmMode
        {
            FRM_TEC_KCB,
            FRM_TEC_ZMAP
        }
        FrmMode curFrmMode;
        YhxxService.YhxxServiceClient yhxxdao = new YhxxService.YhxxServiceClient();

        public delegate void FilterEventHandler(List<TecArrangeEntity> tList);
        public event FilterEventHandler FilterEvent;

        public delegate void FilterDTEventHandler(DataTable dt);
        public event FilterDTEventHandler FilterDTEvent;

        private static FrmTecZmCondi Instance;
        private FrmTecZmCondi()
        {
            InitializeComponent();
        }

        private FrmTecZmCondi(FrmMode frmMode)
            : this()
        {
            this.curFrmMode = frmMode;
        }
        public static FrmTecZmCondi getInstance(FrmMode frmMode)
        {
            Instance = new FrmTecZmCondi(frmMode);
            return Instance;
        }

        private void tsb_ok_Click(object sender, EventArgs e)
        {
            if (txtXyname.Text == string.Empty)
            {
                MessageBox.Show("请填写学员简拼");
                return;
            }
            QueryManage();
        }

        private void QueryManage()
        {
            if (curFrmMode == FrmMode.FRM_TEC_ZMAP)
            {
                TecEntity tecEntity = new TecEntity();
                tecEntity.user_spell = String2pyHelper.GetPYStr(txtXyname.Text);
                List<TecArrangeEntity> taeList = yhxxdao.GetTecArrlist4Zmap(tecEntity).ToList();
                if (FilterEvent != null)
                    FilterEvent(taeList);
            }
            else if (curFrmMode == FrmMode.FRM_TEC_KCB)
            {
                TecEntity tecEntity = new TecEntity();
                tecEntity.user_spell = String2pyHelper.GetPYStr(txtXyname.Text);
                DataTable dt = yhxxdao.GetTec8Entity(tecEntity);
                if (FilterDTEvent != null)
                    FilterDTEvent(dt);
            }
            this.Close();
        }

        private void tsb_exit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
